[filechooser] Unref cancellables we got from the model, not the ones that come into...
authorFederico Mena Quintero <federico@gnome.org>
Fri, 1 Apr 2011 22:06:51 +0000 (16:06 -0600)
committerFederico Mena Quintero <federico@gnome.org>
Fri, 1 Apr 2011 23:00:17 +0000 (17:00 -0600)
The model_cancellables have an extra ref when we get them from gtk_tree_model_get().
So, we need to unref them always.  On the other hand, the cancellables that get
passed as arguments to the callbacks in question are memory-managed by
GtkFileSystemModel.

Reported by Morten Welinder <mortenw@gnome.org>

https://bugzilla.gnome.org/show_bug.cgi?id=646460

gtk/gtkfilechooserbutton.c
gtk/gtkfilechooserdefault.c

index 43da440632cf1e357c7b41e6f626c025f237c151..8b917fb3034e365ec9fa15f6b80e69cc7ca8bd2f 100644 (file)
@@ -1399,7 +1399,7 @@ set_info_get_info_cb (GCancellable *cancellable,
   GdkPixbuf *pixbuf;
   GtkTreePath *path;
   GtkTreeIter iter;
-  GCancellable *model_cancellable;
+  GCancellable *model_cancellable = NULL;
   struct SetDisplayNameData *data = callback_data;
   gboolean is_folder;
 
@@ -1452,7 +1452,8 @@ out:
   gtk_tree_row_reference_free (data->row_ref);
   g_free (data);
 
-  g_object_unref (cancellable);
+  if (model_cancellable)
+    g_object_unref (model_cancellable);
 }
 
 static void
@@ -1578,7 +1579,7 @@ model_add_special_get_info_cb (GCancellable *cancellable,
   GtkTreeIter iter;
   GtkTreePath *path;
   GdkPixbuf *pixbuf;
-  GCancellable *model_cancellable;
+  GCancellable *model_cancellable = NULL;
   struct ChangeIconThemeData *data = user_data;
   gchar *name;
 
@@ -1631,7 +1632,8 @@ out:
   gtk_tree_row_reference_free (data->row_ref);
   g_free (data);
 
-  g_object_unref (cancellable);
+  if (model_cancellable)
+    g_object_unref (model_cancellable);
 }
 
 static inline void
index 23ca7b25c732d9ab04d3f9338a4120b9dad1536c..2022a3d2d81c6bda70890ab281138d175999f3f8 100644 (file)
@@ -763,7 +763,10 @@ shortcuts_free_row_data (GtkFileChooserDefault *impl,
                      -1);
 
   if (cancellable)
-    g_cancellable_cancel (cancellable);
+    {
+      g_cancellable_cancel (cancellable);
+      g_object_unref (cancellable);
+    }
 
   if (!(shortcut_type == SHORTCUT_TYPE_FILE || 
        shortcut_type == SHORTCUT_TYPE_VOLUME) ||
@@ -1457,7 +1460,7 @@ get_file_info_finished (GCancellable *cancellable,
   GdkPixbuf *pixbuf;
   GtkTreePath *path;
   GtkTreeIter iter;
-  GCancellable *model_cancellable;
+  GCancellable *model_cancellable = NULL;
   struct ShortcutsInsertRequest *request = data;
 
   path = gtk_tree_row_reference_get_path (request->row_ref);
@@ -1560,7 +1563,8 @@ out:
   g_free (request->label_copy);
   g_free (request);
 
-  g_object_unref (cancellable);
+  if (model_cancellable)
+    g_object_unref (model_cancellable);
 }
 
 /* FIXME: GtkFileSystem needs a function to split a remote path